﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace xna_game_engine.source
{
    public class SkillWarDevastate : SkillBase
    {
        // * Members * //
        protected int mDmgMin;
        protected int mDmgMax;
        protected int mDmgMult;
        protected int mDmgChance;

        public SkillWarDevastate(BaseCharacter own)
        {
            mDmgMin = 10;
            mDmgMax = 20;
            mDmgMult = 3;
            mDmgChance = 80;
            mOwner = own;
            mRange = 60;
            mName = "Devastate";
            mDescription = "Attacks the target with brutal force, sometimes triggering extra bonus damage.";
            mCoolTimer = new TongaTimer(5.0);
        }

        // Force all children to implement these functions
        override public void Use()
        {
            if (mCoolTimer.Check())
            {
                mCoolTimer.Reset();
                Enemy target = GameGlobals.EnemyManager.GetEnemyClosestToPointWithinRange(mOwner.Position, 150.0f);

                if (null != target)
                {
                    // TODO: Play attack anim for skill
                    if (GameGlobals.RNG.Next(1, 100) < mDmgChance)
                    {
                        // TRIPLE DAMAGE
                        //GameGlobals.CombatText.Trigger(mOwner, "DEVASTATED", Color.Red, 15.0f);
                        target.ModHealth(-GameGlobals.RNG.Next(mDmgMin, mDmgMax) * mDmgMult, Color.Purple);
                    }
                    else
                    {
                        target.ModHealth(-GameGlobals.RNG.Next(mDmgMin, mDmgMax), Color.Red);
                    }

                    if (target.IsDead)
                    {
                        mOwner.AwardKill(target);
                    }
                }
            }
        }

        public override void Update(GameTime gt)
        {
            mCoolTimer.Update(gt);
        }

        // Properties
        public int DamageMultiplier
        {
            get { return mDmgMult; }
            set { mDmgMult = value; }
        }

        public int ExtraDamageChance
        {
            get { return mDmgChance; }
            set { mDmgChance = value; }
        }

        public int MaxDamage
        {
            get { return mDmgMax; }
            set { mDmgMax = value; }
        }

        public int MinDamage
        {
            get { return mDmgMin; }
            set { mDmgMin = value; }
        }
    }
}
